package com.example.lenovo.zyfypt_221yln.fragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.example.lenovo.zyfypt_221yln.R;
import com.example.lenovo.zyfypt_221yln.activity.activity_attention;
import com.example.lenovo.zyfypt_221yln.activity.activity_collection;
import com.example.lenovo.zyfypt_221yln.bean.SessionID;


/**
 * Created by Neusoft on 2017/4/9.
 */

public class Fragment6 extends Fragment {
    private TextView tv_username,tv_realname,tv_rolename,tv_sex;
    private View view=null;
    private Context context;
    private Button button_logout,btn_collect, btn_focus ;

    public Fragment6(Context context) {
        this.context = context;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) {
       //动态加载Fragment6的布局文件
        view=inflater.inflate(R.layout.fragment6,container,false);
        //获取布局上的控件，注意通过view获取
        tv_realname = (TextView) view.findViewById(R.id.textView_realname);
        tv_rolename = (TextView) view.findViewById(R.id.textView_rolename);
        tv_sex = (TextView) view.findViewById(R.id.textView_sex);
        tv_username = (TextView) view.findViewById(R.id.textView_username);
        button_logout = (Button) view.findViewById(R.id.button_logout);
        button_logout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getActivity().finish();
            }
        });

        tv_username.setText(SessionID.username);
        tv_realname.setText(SessionID.realname);
        tv_rolename.setText(SessionID.rolename);
        tv_sex.setText(SessionID.sex);

        btn_collect = (Button) view.findViewById(R.id.btn_collect);
        btn_collect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(),activity_collection.class);
                startActivity(intent);
            }
        });
        btn_focus = (Button) view.findViewById(R.id.btn_focus);
        btn_focus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(),activity_attention.class);
                startActivity(intent);
            }
        });
        //注意Toast第一个参数上下文
        Toast.makeText(context, "加载我", Toast.LENGTH_SHORT).show();
        //返回动态生成的view
        return view;
    }
}
